<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery/jquery-2.1.4.min.js"></script>
</head>

<body>
    <input type="file" id="addBannersImage" multiple="multiple">
    <button id="addBanners">添加轮播图</button>

    <button id="changeTypesById">修改分类</button>
    <button id="usersregister">用户注册</button>
    <button id="userslogin">用户登录</button>
    <button id="getUsers">获取所有用户信息</button>
    <button id="getUsersById">根据id获取用户信息</button>
    <button id="button">新增管理员</button>
    <button id="getall">获取所有</button>
    <button id="getAdminsById">通过ID</button>
    <button id="changeAdminsById">修改</button>
    <button id="changeAdminsStateById">更改权限</button>


    <button id="button">新增管理员</button>
    <button id="adminsLogin">管理员登录</button>
    <button id="getall">获取所有管理员</button>
    <button id="getAdminsById">通过ID获取管理员</button>
    <button id="changeAdminsById">修改管理员</button>
    <button id="changeAdminsStateById">更改管理员的权限</button>


    <button id="addSellers">添加销售人员</button>
    <button id="getAllSellers">获取所有销售人员</button>
    <button id="getSellers">获取销售人员</button>
    <button id="getSellersById">根据_id获取销售人员</button>
    <button id="changeSellersById">根据_id修改销售人员</button>
    <button id="delSellersById">根据_id删除销售人员</button>
    <button id="addTypes">添加保险分类</button>
    <button id="getTypes">获取保险分类</button>
    <button id="getAllTypes">获取所有保险分类</button>
    <button id="delTypesById">根据_id删除保险分类</button>
    <button id="addInsurances">添加保险产品</button>
    <button id="getInsurances">获取保险产品</button>
    <button id="getInsurancesById">根据_id获取保险产品</button>
    <button id="changeInsurancesById">根据_id修改保险产品</button>
    <button id="delInsurancesById">根据_id删除保险产品</button>



    <button id="getOrders">获取所有订单</button>
    <button id="getOrdersById">通过id获取订单</button>
    <button id="disposeOrdersToCancel">修改订单退保信息</button>
    <button id="getBanners">获取轮播图</button>

    <button id="addOrders">添加订单</button>

    <script>
          ordersTime: String,
        $('#addOrders').click(function () {
            $.ajax({
                url: '/orders/addOrders',
                type: 'post',
                data: {
                    ordersTime:"2021-1-5",
                    ordersName:"杰宝",
                    ordersPayState:1,
                    ordersState:2,
                    payPhone:"13111111111",
                    insuresId:"5ff44efb5fd7681df08f7b4e",
                    customersId:"5ff41b6529f3772030690372"
                },
                success(data) {
                    console.log(data);
                }
            })
        })




        $('#getBanners').click(function () {
            $.ajax({
                url: '/banners/getBanners',
                data: {
                    type: "homepage"
                },
                success(data) {
                    console.log(data);
                }
            })
        })



        $("#addBannersImage").change(function (e) {
            // 1. 获取文件上传标签节点（原生节点）
            const node = e.target;
            // 2. 通过node节点获取图片信息
            const files = node.files;
            // 将图片信息保存到表单
            // 3. 创建表单对象
            const formData = new FormData();
            // 4. 将图片信息添加到表单对象中
            for (let key of files) {
                formData.append("file", key)
            }

            $.ajax({
                url: '/banners/addBannersImage',
                type: 'post',
                data: formData,
                contentType: false,
                processData: false,
                cache: false,
                success(data) {
                    console.log(data);
                    if (data.status) {
                        console.log(data.message);
                    }
                }
            })
        })

        $("#addBanners").click(function () {
            $.ajax({
                url: "/banners/addBanners",
                type: "post",
                data: {
                    banners: ["1609500139556-banner1.jpg", "1609500139560-banner2.jpg", "1609500139563-banner3.jpg", "1609500139574-banner4.jpg", "1609500139576-banner5.jpg"],
                    type: "homepage",
                },
                traditional: true,
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })



        $('#changeTypesById').click(function () {
            $.ajax({
                url: '/types/changeTypesById',
                type: 'post',
                data: {
                    _id: '5fec0cfc82bf084de44a0862',
                    typesName: '医疗险',
                },
                success(data) {
                    console.log(data);
                }
            })
        })


        $('#getOrdersById').click(function () {
            $.ajax({
                url: '/orders/getOrdersById',
                type: 'get',
                data: {
                    _id: '5fec7259e5a9d41db03630b6'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#getOrders').click(function () {
            $.ajax({
                url: '/orders/getOrders',
                type: 'get',
                data: {
                    type: 'ordersTime',
                    content: '',
                    currentPage: '1',
                    pageSize: '100'
                },
                success(data) {
                    console.log(data);
                }
            })
        })

        $('#disposeOrdersToCancel').click(function () {
            $.ajax({
                url: '/orders/disposeOrdersToCancel',
                type: 'post',
                data: {
                    _id: '5fec7259e5a9d41db03630b6',
                    ordersState: 1
                },
                success(data) {
                    console.log(data);
                }
            })
        })

        $('#userslogin').click(function () {
            $.ajax({
                url: '/users/login',
                type: 'post',
                data: {
                    userName: '王五',
                    passWord: '1234567'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#usersregister').click(function () {
            $.ajax({
                url: '/users/register',
                type: 'post',
                data: {
                    userName: '王五',
                    passWord: '1234567'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#button').click(function () {
            $.ajax({
                url: '/admins/addAdmins',
                type: 'post',
                data: {
                    adminsUserName: '王六'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#getall').click(function () {
            $.ajax({
                url: '/admins/getAdmins',
                type: 'get',
                data: {
                    content: '',
                    currentPage: '1',
                    pageSize: '1'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#getAdminsById').click(function () {
            $.ajax({
                url: '/admins/getAdminsById',
                type: 'get',
                data: {
                    _id: '5fec21d777c8af2f10b5793a'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#changeAdminsById').click(function () {
            $.ajax({
                url: '/admins/changeAdminsById',
                type: 'post',
                data: {
                    _id: '5fed43fd8fc6c226b05efb12',
                    adminsUserName: '张',
                    adminsPassword: 'wshcx'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#changeAdminsStateById').click(function () {
            $.ajax({
                url: '/admins/changeAdminsStateById',
                type: 'post',
                data: {
                    _id: '5fec21d777c8af2f10b5793a',
                    adminsState: '1'
                },
                success(data) {
                    console.log(data);
                }
            })
        })
        $('#adminsLogin').click(function () {
            $.ajax({
                url: '/admins/adminsLogin',
                type: 'post',
                data: {
                    adminsUserName: 'hcx',
                    adminsPassword: '123456'
                },
                success(data) {
                    console.log(data);
                }
            })
        })

        $("#addSellers").click(function () {
            $.ajax({
                url: "/sellers/addSellers",
                type: "post",
                data: {
                    sellersName: "王五",
                    sellersAccount: 'wangwu',
                    sellersPassword: '123',
                    state: 1,
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })

        $("#getAllSellers").click(function () {
            $.ajax({
                url: "/sellers/getAllSellers",
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })
        $("#getSellers").click(function () {
            $.ajax({
                url: "/sellers/getSellers",
                data: {
                    searchSellers: "",
                    pageSize: '5',
                    currentPage: '1',
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })
        $("#getSellersById").click(function () {
            $.ajax({
                url: "/sellers/getSellersById",
                data: {
                    _id: "5febf3eba40b053ed082bfa4"
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })
        $("#changeSellersById").click(function () {
            $.ajax({
                url: "/sellers/changeSellersById",
                type: "post",
                data: {
                    _id: "5febfd6821e15e439422a6cb",
                    sellersName: "李四李四",
                    sellersAccount: '李四',
                    sellersPassword: '12345',

                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })
        $("#delSellersById").click(function () {
            $.ajax({
                url: "/sellers/delSellersById",
                type: "post",
                data: {
                    _id: "5febfd7521e15e439422a6cc",
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })
        $("#addTypes").click(function () {
            $.ajax({
                url: "/types/addTypes",
                type: "post",
                data: {
                    typesName: "医疗险",
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })

        $("#getTypes").click(function () {
            $.ajax({
                url: "/types/getTypes",
                type: "post",
                success(data) {
                    console.log(data);
                }
            })
        })

        $("#getAllTypes").click(function () {
            $.ajax({
                url: "/types/getAllTypes",
                type: "get",
                success(data) {
                    console.log(data);
                }
            })
        })



        $("#delTypesById").click(function () {
            $.ajax({
                url: "/types/delTypesById",
                type: "post",
                data: {
                    _id: "5fec0d2782bf084de44a0863",
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })


        $("#addInsurances").click(function () {
            $.ajax({
                url: "/insurances/addInsurances",
                type: "post",
                data: {
                    insurancesName: "意外车险",
                    insurancesPayType: "网络缴费",
                    insurancesSuitableFor: "18周岁~60周岁",
                    insurancesRenew: true,
                    insurancesPolicy: ["年保"],
                    insurancesPrice: "300",
                    typesId: "5fec0cfc82bf084de44a0862"
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })

        $("#getInsurances").click(function () {
            $.ajax({
                url: "/insurances/getInsurances",
                data: {
                    type: "insurancesName",
                    value: "",
                    pageSize: '5',

                    currentPage: '1',
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })

        $("#getInsurancesById").click(function () {
            $.ajax({
                url: "/insurances/getInsurancesById",
                data: {
                    _id: "5fec3ca4992c8f2cac2cbf21"
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })


        $("#changeInsurancesById").click(function () {
            $.ajax({
                url: "/insurances/changeInsurancesById",
                type: "post",
                data: {
                    _id: "5fec3ca4992c8f2cac2cbf21",
                    // insurancesName: "教育险",
                    insurancesPayType: "纸面缴费",
                    insurancesSuitableFor: "全年龄段",
                    insurancesRenew: false,
                    insurancesPolicy: ["半年保"],
                    insurancesPrice: "810",
                    typesId: "5fec0d3482bf084de44a0864"

                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })

        $("#delInsurancesById").click(function () {
            $.ajax({
                url: "/insurances/delInsurancesById",
                type: "post",
                data: {
                    _id: "5fec3c6d992c8f2cac2cbf20",
                },
                success(data) {
                    if (data.status) {
                        console.log(data);
                        console.log(data.message)
                    } else {
                        console.log(data.message)
                    }
                }
            })
        })

    </script>
</body>

</html>